<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>天朝企业</title>
<%@include file="/view/common/js-css.jsp"%>
</head>
<body>
	<center>
		<h1>修改密码</h1>
	</center>
	<c:if test="${!empty param.oldpasswordError }">
		<div class="alert alert-danger alert-dismissible fade in" role="alert"
			style="text-align: center;">
			<button type="button" class="close" data-dismiss="alert"
				aria-label="Close">
				<span aria-hidden="true">×</span>
			</button>
			<strong>原密码错误！</strong>
		</div>
	</c:if>
	<c:if test="${!empty param.repasswordError }">
		<div class="alert alert-danger alert-dismissible fade in" role="alert"
			style="text-align: center;">
			<button type="button" class="close" data-dismiss="alert"
				aria-label="Close">
				<span aria-hidden="true">×</span>
			</button>
			<strong>新密码重复输入不同！</strong>
		</div>
	</c:if>
	<div class="container">
		<form class="form-horizontal" role="form"
			action="<%=request.getContextPath()%>/CompanyServlet?command=resetPassword"
			method="post" onsubmit="return validate();">
			<span class="label label-danger">${error }</span>
			<div class="form-group">
				<label for="name" class="col-sm-2 control-label"
					style="margin-left: -80px;">code</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="code"
						placeholder="code" id="code" readonly="readonly" value="${code}">
				</div>
				<span id="codeInfo" class="bg-danger text-muted"></span>
			</div>
			<div class="form-group">
				<label for="newPassword" class="col-sm-2 control-label"
					style="margin-left: -80px;">new-password</label>
				<div class="col-sm-10">
					<input type="password" class="form-control" name="newPassword"
						id="newPassword">
				</div>
				<span id="pwdInfo2" class="bg-danger text-muted"></span>
			</div>
			<div class="form-group">
				<label for="rePassword" class="col-sm-2 control-label"
					style="margin-left: -80px;">re-password</label>
				<div class="col-sm-10">
					<input type="password" class="form-control" name="rePassword"
						id="rePassword">
				</div>
				<span id="pwdInfo3" class="bg-danger text-muted"></span>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10"">
					<button type="submit" class="btn btn-default">修改</button>
					<a class="btn btn-primary"
						href="<%=request.getContextPath()%>/CompanyServlet?command=main">返回</a>
				</div>
			</div>
		</form>
	</div>
	<script>
		/**
		 * 表单验证
		 */
		function validate() {
			var result = true;
			var newPassword = document.getElementById("newPassword");
			var rePassword = document.getElementById("rePassword");
			if (newPassword.value == '') {
				document.getElementById("pwdInfo2").innerHTML = "新密码不能为空";
				result = false;
			} else {
				document.getElementById("pwdInfo2").innerHTML = "";
			}
			if (rePassword.value == '') {
				document.getElementById("pwdInfo3").innerHTML = "新密码不能为空";
				result = false;
			} else {
				document.getElementById("pwdInfo3").innerHTML = "";
			}

			return result;
		}
		/**
		 *el获取是否修改成功信息(相当于request.getParameter(arg0))
		 */
		if ('${param.updateSuccess}') {
			layer.msg('修改成功！', {
				icon : 1
			});
		}
		if ('${param.updateError}') {
			layer.msg('修改失败！', {
				icon : 0
			});
		}
	</script>
</body>
</html>